package com.quanyan.pay.api.alipay.service;

import com.alipay.api.AlipayClient;
import com.alipay.api.response.*;
import com.quanyan.pay.api.alipay.vo.*;
import com.quanyan.pay.entity.AlipayConfigAccount;

import java.util.Map;

/**
 * Created by Zheng.Ke
 * Date 2017/3/15.
 */
public interface AlipayAPIService {

    /**
     * 初始化AlipayClient
     * @param alipayConfigAccount
     * @return
     */
    AlipayClient initAlipayClient(AlipayConfigAccount alipayConfigAccount);

    /**
     * 手机网站支付接口
     * 具体参见文档  https://doc.open.alipay.com/doc2/detail.htm?treeId=203&articleId=105463&docType=1
     * @param vo
     * @return
     */
    AliTradeWapPayRespVo tradeWapPay(AliTradeWapPayReqVo vo);

    /**
     * 交易查询接口
     * 具体参见文档  https://doc.open.alipay.com/doc2/apiDetail.htm?apiId=757&docType=4
     * @param vo
     * @return
     */
    AlipayTradeQueryResponse tradeQuery(AliTradeQueryReqVo vo);

    /**
     * 交易关闭接口
     * 具体参见文档  https://doc.open.alipay.com/doc2/apiDetail.htm?apiId=1058&docType=4
     * @param vo
     * @return
     */
    AlipayTradeCloseResponse tradeClose(AliTradeCloseReqVo vo);

    /**
     * 统一收单交易支付接口（条码支付）
     * 具体参见文档  https://doc.open.alipay.com/doc2/apiDetail.htm?spm=a219a.7629065.0.0.PlTwKb&apiId=850&docType=4
     * @param vo
     * @return
     */
    AlipayTradePayResponse tradePay(AliTradePayReqVo vo);

    /**
     * 统一收单交易退款接口
     * 具体参见文档  https://doc.open.alipay.com/doc2/apiDetail.htm?spm=a219a.7629065.0.0.PlTwKb&apiId=759&docType=4
     * @param vo
     * @return
     */
    AlipayTradeRefundResponse tradeRefund(AliTradeRefundReqVo vo);

    /**
     * 统一收单交易退款查询接口
     * 具体参见文档  https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.OlNgGO&docType=4&apiId=1049
     * @param vo
     * @return
     */
    AlipayTradeFastpayRefundQueryResponse tradeFastpayRefundQuery(AliTradeFastpayRefundQueryReqVo vo);

    /**
     * App支付接口
     * 具体参见文档  https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.svMVrv&treeId=204&articleId=105465&docType=1
     * @param vo
     * @return
     */
    AliTradeAppPayRespVo tradeAppPay(AliTradeAppPayReqVo vo);

    /**
     * 校验签名
     * @param paramsMap           支付宝回调参数map
     * @param alipayPublicKey     支付宝公钥（若不清楚，请去open.alipay.com对应应用下查看）
     * @return
     */
    boolean verifySign(Map<String, String> paramsMap, String alipayPublicKey);

    /**
     * 单笔转账到支付宝账户接口
     * 具体参见文档  https://doc.open.alipay.com/docs/api.htm?apiId=1321&docType=4
     * @param vo
     * @return
     */
    AlipayFundTransToaccountTransferResponse fundTransToAccountTransfer(AliFundTransToAccountTransferReqVo vo);

    /**
     * 查询转账订单接口
     * 具体参见文档  https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.HuKQRY&docType=4&apiId=1322
     * @param vo
     * @return
     */
    AlipayFundTransOrderQueryResponse fundTransOrderQuery (AliFundTransOrderQueryReqVo vo);

    /**
     * 查询账单下载地址接口
     * 具体参见文档  https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.9M3HD2&treeId=203&articleId=105287&docType=1
     * @param vo
     * @return
     */
    AlipayDataDataserviceBillDownloadurlQueryResponse dataDataserviceBillDownloadurlQuery(AliDataDataserviceBillDownloadurlQueryReqVo vo);

    /**
     * 下载并解析对账单
     * 具体参见CSV文件  获取文件方式  step1: 访问查询账单下载地址接口，拿到下载链接  step2: 将链接复制到浏览器上并下载文件  PS：链接只有30s的可下载时间
     * @param billDownloadUrl
     * @return
     */
    AliBillDataRespVo downloadAndProcessBillData(String billDownloadUrl);

    /**
     * 下载并解析对账单
     * 具体参见CSV文件  获取文件方式  step1: 访问查询账单下载地址接口，拿到下载链接  step2: 将链接复制到浏览器上并下载文件  PS：链接只有30s的可下载时间
     * @param vo
     * @return
     */
    AliBillDataRespVo downloadAndProcessBillData(AliDataDataserviceBillDownloadurlQueryReqVo vo);




}
